﻿using System;

namespace Basmus.ReadWrite
{
    public class GuidReaderWriter : IReaderWriter<Guid>
    {
        public ReadResult<Guid> Read(string s)
        {
            Guid value;
            if (Guid.TryParse(s, out value))
            {
                return ReadResult<Guid>.Success(value);
            }
            return ReadResult<Guid>.Error();
        }

        public string Write(Guid value)
        {
            return value.ToString();
        }
    }
}